#ifndef _MAIN_H
#define _MAIN_H

#include <gtk/gtk.h>
#include <amanita/aApplication.h>
#include "occult/Occult.h"


#define APP_PROJECT				"mantichora"
#define APP_TITLE					"Mantichora Tools v0.1"
#define APP_USER_AGENT			"Mantichora"

#define WEB_HOST					"mantichora.net"
#define WEB_PATH					"/tools/"


enum {
	ACTION_NEW						= 0x00010001,
	ACTION_OPEN						= 0x00010002,
	ACTION_CLOSE					= 0x00010003,
	ACTION_LOGINOUT				= 0x00010011,
	ACTION_PRINT					= 0x00010021,
	ACTION_PREVIEW					= 0x00010022,
	ACTION_QUIT						= 0x00010091,
	ACTION_HOROSCOPE				= 0x00011001,
	ACTION_HERENOW					= 0x00011002,
	ACTION_NATAL					= 0x00011003,
	ACTION_SOLAR					= 0x00011004,
	ACTION_SYNASTRY				= 0x00011005,
	ACTION_COMPOSIT				= 0x00011006,
	ACTION_COMSYN					= 0x00011007,
	ACTION_PLANETS					= 0x00011101,
	ACTION_ASPECTS					= 0x00011102,
	ACTION_STATISTICS				= 0x00011008,
	ACTION_SEARCH					= 0x00011009,
	ACTION_WORDLIST				= 0x00012001,
	ACTION_TERMINOLOGY			= 0x00012002,
	ACTION_LANGS					= 0x00012003,
	ACTION_SYMLEX					= 0x00012004,
	ACTION_TRANSLATION			= 0x00012005,
	ACTION_GEMATRIA				= 0x00012006,
	ACTION_ALPHABET				= 0x00012007,
	ACTION_SYMBOLS					= 0x00012008,
	ACTION_CORRESPONDENCE		= 0x00012009,
	ACTION_QABALAH					= 0x0001200a,
	ACTION_ENOCHIAN				= 0x0001200b,
	ACTION_ALCHEMY					= 0x0001200c,
	ACTION_RITUALS					= 0x0001200d,
	ACTION_TAROTDECKS				= 0x00013001,
	ACTION_TAROTSTARS				= 0x00013002,
	ACTION_TAROTDIVINATION		= 0x00013003,
	ACTION_JOURNAL					= 0x00014001,
	ACTION_LIBRARY					= 0x00014002,
	ACTION_CLASSES					= 0x00014003,
	ACTION_MESSAGES				= 0x00014004,
	ACTION_FORUM					= 0x00014005,
	ACTION_CHAT						= 0x00014006,
	ACTION_CONTENT					= 0x00015001,
	ACTION_ABOUT					= 0x00015002,

	ACTION_SHOW_STATUS			= 0x00018001,
	ACTION_LOGIN					= 0x00018011,
	ACTION_LOGOUT					= 0x00018012,
};


class Occult;
class Page;
class ProfileDlg;
class PlanetsDlg;


class MainFrame : public aApplication {
private:
	struct menu_item {
		const char *pid;
		const char *id;
		int code;
		bool sensitive;
		int acc;
		int acc_mod;
		int index;
		int lvl;
		const char *name;
		const char *status;
		menu_item *parent;
		menu_item *child;
		GtkWidget *item;
		GtkWidget *submenu;
	};

	struct {
		GtkWidget *window;
		GtkWidget *menubar;
		GtkWidget *notebook;
		GtkWidget *statusbar;
	} gui;

	menu_item *items;
	aHashtable menu;
	aHashtable images;
	aHashtable surfaces;

public:
	char local_user[32];
	char local_password[32];
	char local_key[256];
	Occult occult;
	ProfileDlg *profile_dlg;
	PlanetsDlg *planets_dlg;

	MainFrame();
	~MainFrame();

	bool init(int argc,char *argv[]);

	void init();
	void exit();

	int handleAction(int code,int p1=0,void *p2=0);

	GdkPixbuf *getImage(const char *fn);
	GdkPixbuf *loadImage(const char *fn);
	cairo_surface_t *getSurface(const char *fn);

	void setLanguage(const char *l);
	FILE *fopenlangf(char *path,const char *fn, ...);

	void openPage(Page &page);
	bool closePage(Page *page=0);
	int getPageIndex(Page &page);

	void showStatus(const char *msg,int index=0);
	void removeStatus(int index=0);
};

extern MainFrame app;


#endif /* _MAIN_H */

